﻿Public Class WebForm4
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim weight, height As Single
        weight = CSng(tb_weight.Text)
        height = CSng(tb_height.Text)
        Dim result As Single
        result = weight / (height ^ 2)
        Total.Text = CStr(result)
        Label4.Text = getResult(Total.Text)

        Dim body As New HtmlGenericControl
        body = Master.FindControl("bdycontrol")
        If CSng(result) < 17.5 Then
            body.Attributes("bgcolor") = "LightBlue"
        ElseIf CSng(result) > 30 Then
            body.Attributes("bgcolor") = "Red"
        Else
            body.Attributes("bgcolor") = "Green"
        End If
    End Sub

    Private Function getResult(ByVal percentageString As String) As String
        Dim percentage As Single
        percentage = CSng(percentageString)


        Select Case percentage
            Case Is > 30
                Return ">30%"
            Case Is < 17.5
                Return "<17.5%"
            Case Else
                Return "OK"
        End Select
    End Function





End Class